package com.sfzy.controller;

import com.sfzy.Service.SeleArtService;
import com.sfzy.entity.SeleArt;
import com.sfzy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("seleArt")
public class SeleArtController {
    @Autowired
    private SeleArtService seleArtService;

    @PostMapping
    public R add(@RequestBody SeleArt seleArt) {
        return R.ok(seleArtService.addSeleArt(seleArt));
    }

    @PutMapping
    public R update(@RequestBody SeleArt seleArt) {
        return R.ok(seleArtService.updateSeleArt(seleArt));
    }

    @DeleteMapping("{id}")
    public R delete(@PathVariable("id") int id) {
        return R.ok(seleArtService.deleteSeleArt(id));
    }

    @GetMapping("{id}")
    public R get(@PathVariable("id") int id) {
        return R.ok(seleArtService.getSeleArt(id));
    }

    @GetMapping("page")
    public R getPage(SeleArt seleArt,
                     @RequestParam(required = false,defaultValue = "1") int pageNum,
                     @RequestParam(required = false,defaultValue = "6") int pageSize) {
        return R.ok(seleArtService.getAllSeleArt(seleArt, pageNum, pageSize));
    }
}
